#include "forward_session.h"
#include "common.h"
#include "forward_util.h"
#include <string>
#include <sstream>
using namespace std;


forward_session::forward_session(forward_pair& fwd_pair){
	init();
	set_pair(fwd_pair);

	td.session_ptr = this;
}

void forward_session::init(){
	ar = true;
	reset();
}

forward_session::~forward_session(){
	LOGI("~forward_session %s", to_string());
	if (ar){
		close();
	}	
}

void forward_session::close(){
	LOGI("close %s", to_string());
}

void forward_session::reset(){	
	evt_in.reset();
	evt_out.reset();
}

const char* forward_session::to_string(){
	static char tmp [128] = {0};
	sprintf(tmp, "<session-%d>", (int)(this));
	return tmp;
}

void forward_session::auto_release(bool ar){
	this->ar = ar;
}
